<template>
  <div class="history-session-box">
    <div class="msg-head">
      <div>
        <div class="msg-head-city">{{ info.name }}<span>客户</span></div>
        <div class="msg-head-tip">首次会话</div>
      </div>
      <div class="msg-menu">
        <div class="msg-menu-item">
          <img src="./add_u334.svg" alt="" />
          <span @click="NewGongdan">创建工单</span>
        </div>
        <div class="msg-menu-item">
          <img src="./u402.svg" alt="" />
          <span @click="lahei">拉黑</span>
        </div>
        <router-link to="/main/huihua">
          <div class="msg-menu-item">
            <img src="./u967.svg" alt="" />
            <span>发起会话</span>
          </div>
        </router-link>
      </div>
    </div>
    <div style="clear: both"></div>
    <div style="display: flex">
      <div class="msg-window">
        <div class="msg-window-main" ref="msg_window_main_history_sessionbox">
          <span>更多记录</span>
          <div class="msg-left">
            <div class="msg-left-head">
              <img src="./u327.png" alt="" />
            </div>
            <div class="msg-left-title">
              {{ info.name }}客户 {{ info.time }}
            </div>
            <div class="msg-left-msg">{{ info.content }}</div>
          </div>
          <div class="msg-right-panel">
            <div class="msg-right" v-for="msg in msgList" :key="msg.time">
              <div>
                <div class="msg-right-title">10号客服{{ msg.time }}</div>
                <div class="msg-right-msg">{{ msg.content }}</div>
              </div>
              <div class="msg-right-head">
                <img src="./u309.svg" alt="" />
              </div>
            </div>
          </div>
        </div>
        <div class="msg-window-input">
          <div class="msg-window-input-head">
            <img src="./u316.svg" alt="" />
            <img src="./u317.svg" alt="" />
          </div>
          <div class="msg-window-input-history-session-box">
            <textarea
              name=""
              id=""
              cols="95"
              rows="2"
              placeholder="请输入内容"
              v-model="messages"
              @keyup.enter="SendMsg"
            ></textarea>
          </div>
          <div class="msg-window-input-submit" @click="SendMsg">
            <my-button :color="true" width="100">发送</my-button>
          </div>
        </div>
      </div>
      <div class="msg-panel">
        <div class="msg-panel-head">
          <el-tabs v-model="activeName">
            <el-tab-pane label="资料" name="info">
              <session-box-item :infoItems="fangkeItems"></session-box-item>
              <div style="padding: 0 20px">
                <el-divider></el-divider>
              </div>
              <session-box-item :infoItems="kehuItems" edit="true">
                <span class="session-box-item-label">客户标签</span>
                <span
                  ><el-tag type="success">已上市</el-tag>
                  <span style="padding: 5px"></span>
                  <el-tag type="success">潜在客户</el-tag></span
                >
              </session-box-item>
            </el-tab-pane>
            <el-tab-pane label="会话数据" name="usual">
              <session-box-item :infoItems="baseDataItems"></session-box-item>
              <div style="padding: 0 20px">
                <el-divider></el-divider>
              </div>
              <session-box-item :infoItems="pingjiaItems"></session-box-item>
            </el-tab-pane>
            <el-tab-pane label="历史工单" name="history">
              <session-box-item :infoItems="lishiItems">
                <span style="float: right; margin-right: 20px">
                  <router-link to="/main/gongdandetail">
                    <el-button type="text"
                      >查看工单详情 <i class="el-icon-arrow-right"></i>
                    </el-button>
                  </router-link>
                </span>
              </session-box-item>
            </el-tab-pane>
          </el-tabs>
        </div>
      </div>
    </div>
    <my-dialog
      title="拉黑客户"
      :show="laheiDialog"
      width="500"
      v-if="laheiDialog"
      @close="close"
    >
      <lahei fname="sessionBox-lahei" @close="close"></lahei>
    </my-dialog>

    <my-dialog
      title="新建工单"
      :show="NewGongdanDialog"
      width="500"
      v-if="NewGongdanDialog"
      @close="close"
    >
      <new-gongdan fname="sessionBox-closeSession" @close="close"></new-gongdan>
    </my-dialog>
  </div>
</template>

<script>
import MyButton from "@/components/MyInput/MyButton";
import SessionBoxItem from "@/components/Session/SessionBox/SessionBoxItem";
import MyDialog from "@/components/MyInput/MyDialog";
import NewGongdan from "@/components/Session/NewGongdan";
import Lahei from "@/components/Session/Lahei";
export default {
  props: ["info"],
  components: {
    SessionBoxItem,
    MyButton,
    MyDialog,
    Lahei,
    NewGongdan
  },
  created() {
    this.addMsg({
      content: "您好，请问有什么可以帮您呢？",
      time: "2020/06/09 20:09",
    });
  },
  data() {
    return {
      laheiDialog: false,
      NewGongdanDialog: false,
      msgList: [],
      messages: "",
      activeName: "info",
      activeName2: "",
      search: "",
      IsPerson: true,
      fangkeItems: {
        name: "访客信息",
        items: [
          {
            label: "来源",
            info: "113.128.230.51",
          },
          {
            label: "IP地址",
            info: "113.128.230.51",
          },
          {
            label: "浏览器",
            info: "Chrome 81.0.4044.138",
          },
          {
            label: "屏幕尺寸",
            info: "1440 x 900",
          },
          {
            label: "设备",
            info: "Mac",
          },
        ],
      },
      kehuItems: {
        name: "客户信息",
        items: [
          {
            label: "客户名称",
            info: "北京市客户",
          },
          {
            label: "真实姓名",
            info: "王伟",
          },
          {
            label: "客户电话",
            info: "-",
          },
          {
            label: "客户邮箱",
            info: "-",
          },
          {
            label: "客户公司",
            info: "-",
          },
          {
            label: "客户地址",
            info: "-",
          },
          {
            label: "客户等级",
            info: "普通客户",
          },
          {
            label: "客户来源",
            info: "访客转化",
          },
          {
            label: "客户备注",
            info: "-",
          },
        ],
      },
      lishiItems: {
        name: "工单信息",
        items: [
          {
            label: "工单标题",
            info: "分类一",
          },
          {
            label: "工单描述",
            info: "客户需要型号SU-CC8990的产品的详细报价，请速联系。",
          },
          {
            label: "工单分类",
            info: "分类一",
          },
          {
            label: "抄送人",
            info: "王涛，吴敏儿",
          },
          {
            label: "优先级",
            info: "低",
          },
          {
            label: "工单状态",
            info: "处理中",
          },
          {
            label: "受理客服组",
            info: "客服组一",
          },
          {
            label: "受理客户",
            info: "王先生",
          },
          {
            label: "创建时间",
            info: "2020/06/09 20:09",
          },
          {
            label: "更新时间",
            info: "2020/06/09 20:09",
          },
        ],
      },
      baseDataItems: {
        name: "基础数据",
        items: [
          {
            label: "开始时间",
            info: "2020-05-16 09:50:21",
          },
          {
            label: "结束时间",
            info: "2020-05-16 22:40:17",
          },
          {
            label: "持续时长",
            info: "49 分 51 秒",
          },
          {
            label: "平均响应时长",
            info: "49 分 51 秒",
          },
          {
            label: "首次响应时长",
            info: "49 分 51 秒",
          },
          {
            label: "顾客消息数",
            info: "10",
          },
          {
            label: "客服消息数",
            info: "11",
          },
        ],
      },
      pingjiaItems: {
        name: "评价",
        items: [
          {
            label: "评价时间",
            info: "2020-05-16 09:50:21",
          },
          {
            label: "评价",
            info: "好评",
          },
          {
            label: "评价详情",
            info: "很好很不错，解决了",
          },
        ],
      },
    };
  },
  methods: {
    lahei() {
      this.laheiDialog = true;
    },
    addMsg(msg) {
      this.msgList.push(msg);
    },
    NewGongdan () {
      this.NewGongdanDialog = true
    },
    close() {
      this.laheiDialog = false;
      this.zhuanjieDialog = false
      this.closeSessionDialog = false
      this.NewGongdanDialog = false
    },
    SendMsg() {
      if (this.messages === "" || this.messages === "\n") {
        this.$message.error("请输入内容");
        return;
      }
      console.log("send a msg");
      this.addMsg({
        content: this.messages,
        time: this.getTime(),
      });
      setTimeout(() => {
        this.messages = "";
        this.$refs.msg_window_main_history_sessionbox.scrollTop = this.$refs.msg_window_main_history_sessionbox.scrollHeight;
      }, 100);
    },
    getTime() {
      var now = new Date();
      var yy = now.getFullYear(); //年
      var mm = now.getMonth() + 1; //月
      var dd = now.getDate(); //日
      var hh = now.getHours(); //时
      var ii = now.getMinutes(); //分
      var ss = now.getSeconds(); //秒
      var clock = yy + "-";
      if (mm < 10) clock += "0";
      clock += mm + "-";
      if (dd < 10) clock += "0";
      clock += dd + " ";
      if (hh < 10) clock += "0";
      clock += hh + ":";
      if (ii < 10) clock += "0";
      clock += ii + ":";
      if (ss < 10) clock += "0";
      clock += ss;
      return clock;
    },
  },
};
</script>

<style>
.history-session-box {
  width: 1040px;
  height: 700px;
  background-color: white;
  margin-left: 10px;
  border-radius: 4px;
}

.history-session-box .msg-head {
  width: 100%;
  height: 50px;
  border-bottom: 1px solid rgb(242, 242, 242);
  display: flex;
  justify-content: space-between;
}

.history-session-box .msg-head .msg-head-city {
  display: inline-block;
  font-size: 16px;
  line-height: 50px;
  margin-left: 20px;
}

.history-session-box .msg-head .msg-head-tip {
  display: inline-block;
  font-size: 14px;
  line-height: 50px;
  color: #cccccc;
  padding: 5px;
}

.history-session-box .msg-menu {
  display: flex;
  float: right;
  margin: 20px;
}

.history-session-box .msg-menu .msg-menu-item {
  color: #006eff;
  font-size: 14px;
}

.history-session-box .msg-menu .msg-menu-item span {
  padding: 8px;
}

.history-session-box .msg-window-main {
  height: 500px;
  width: 700px;
  background-color: rgba(242, 242, 242, 0.498039215686275);
  overflow: auto;
}

.history-session-box .msg-window-input {
  width: 700px;
  height: 150px;
}

.history-session-box .msg-window-input-head {
  height: 45px;
}

.history-session-box .msg-window-input-head img {
  margin-left: 15px;
  margin-top: 10px;
}

.history-session-box .msg-window-input-history-session-box {
  padding: 10px 10px;
}

.history-session-box .msg-window-input-history-session-box textarea {
  border-style: none;
  outline-style: none;
  resize: none;
  font-family: "ArialMT", "Arial", sans-serif;
}

.history-session-box .msg-window-input-session-box ::-webkit-input-placeholder {
  color: rgb(204, 204, 204);
}

.history-session-box .msg-window-input-submit {
  float: right;
}

.history-session-box .msg-window-main > span {
  display: inline-block;
  font-size: 12px;
  color: #cccccc;
  padding-top: 10px;
  width: 100%;
  text-align: center;
}

.history-session-box .msg-window-main .msg-left-head {
  float: left;
  width: 40px;
  height: 40px;
  background-color: rgba(0, 110, 255, 0.898039215686275);
  border-radius: 50%;
  text-align: center;
  line-height: 50px;
  margin-left: 20px;
  margin-top: 20px;
  margin-right: 8px;
}

.history-session-box .msg-window-main .msg-left-head img {
  width: 20px;
  height: 20px;
}

.history-session-box .msg-window-main .msg-left-title {
  display: inline-block;
  font-size: 12px;
  color: #cccccc;
  position: relative;
  top: 18px;
}

.history-session-box .msg-window-main .msg-left-msg {
  clear: both;
  background-color: white;
  width: 219px;
  height: 40px;
  border-radius: 4px;
  box-shadow: 0px 0px 5px rgba(204, 204, 204, 1);
  text-align: center;
  line-height: 40px;
  font-size: 14px;
}

.history-session-box .msg-window-main .msg-left-msg {
  position: relative;
  left: 75px;
  top: -20px;
}

.history-session-box .msg-right {
  float: right;
  display: flex;
  justify-content: flex-end;
  margin: 10px 0;
}
.history-session-box .msg-window-main .msg-right-head {
  width: 40px;
  height: 40px;
  background-color: darkgray;
  border-radius: 50%;
  text-align: center;
  line-height: 50px;
  margin: 0 10px;
}

.history-session-box .msg-window-main .msg-right-head img {
  width: 15px;
  height: 15px;
}

.history-session-box .msg-window-main .msg-right-title {
  font-size: 12px;
  color: #cccccc;
  float: right;
  margin: 5px 0;
}

.history-session-box .msg-window-main .msg-right-msg {
  clear: both;
  background-color: white;
  max-width: 500px;
  min-height: 40px;
  border-radius: 4px;
  box-shadow: 0px 0px 5px rgba(204, 204, 204, 1);
  text-align: center;
  line-height: 40px;
  font-size: 14px;
  overflow-wrap: break-word;
  padding: 0 5px;
}

.history-session-box .msg-right-panel {
  float: right;
  display: flex;
  width: 600px;
  flex-direction: column;
}

.msg-panel-head .el-tabs__header {
  width: 340px;
  line-height: 64px;
}

.msg-panel-head .el-tabs__item {
  padding-right: 60px;
}

.msg-panel-head .el-tabs__nav {
  right: -20px;
}

.msg-panel-head .el-tabs__item.is-active {
  color: #006eff;
}
</style>